#!/bin/sh 
substrA="mmcblk0"
substrB="mmcblk0p"
mountbase_point="/dev/mmcblk0"
result_mount=255
##create dir
mounted=`mount | grep $1 | wc -l`
#echo "^^^^^^^^^^^^^^^^^$mounted" >>/tmp/hot.log
if [ $mounted -ge 1 ]; then
#	echo "++++++++++++++++++++++++++++++++++" >>/tmp/hot.log
	MOUNTS=$(mount | grep $substrA | cut -d' ' -f3)
	echo $MOUNTS >>/tmp/hot.log
	umount $MOUNTS
	rm -rf $MOUNTS
else

	if [ ! -d /mnt/media ]; then
      mkdir -p /mnt/media
	fi
	for i in `ls /dev/`; 
	do  

		result=$(echo $i | grep "$substrB")
		if [[ "$result" != "" ]]
		then
			if [ ! -d /mnt/media/$i ]; then
				 mkdir -p /mnt/media/$i
			fi
		   mount /dev/$i /mnt/media/$i
			
		   result_mount=$?
		   mkdir -p /mnt/media/$i/5M
	           mkdir -p /mnt/media/$i/100M
		   break;
		else
		   echo " $i xx $substrB  =>$result"
		fi
	done
#	echo "#################=>$result_mount" >>/tmp/hot.log
	if [[ $result_mount != 0 ]]
	then
		if [ ! -d /mnt/media/mmcblk0 ]; then
				 mkdir -p /mnt/media/mmcblk0
		fi
		mount $mountbase_point /mnt/media/mmcblk0
		mkdir -p /mnt/media/mmcblk0/5M
                mkdir -p /mnt/media/mmcblk0/100M
	fi
	echo $?
fi
